/**
 * @Description Ext.translate for ExtJS 2.x and 3.x; Auto translation with Google Translation API (java/php server side)
 * @author  Tomislav Milkovic
 * @license LGPLv3 http://www.opensource.org/licenses/lgpl-3.0.html
 * @version 1.5, 05.08.2009.
 */

/**
 * @Decription Add after Ext.translate.js in html. This will disable server side calls and all translation requests
 * will be sent directly to Google Tranlation Service. With this option, server translation cache is disabled, as
 * also possibility to modify cached translated data. Client only version does not need any server side services.  
 */
Ext.translate.clientonly=true;
Ext.translate.languages = [['sq', 'ALBANIAN', 'ux-flag-sq'],['ar', 'ARABIC', 'ux-flag-ar'],['bg', 'BULGARIAN', 'ux-flag-bg'],
                           ['ca', 'CATALAN', 'ux-flag-ca'],['zh', 'CHINESE', 'ux-flag-zh'],['zh-CN', 'CHINESE_SIMPLIFIED', 'ux-flag-zh-CN'],
                           ['zh-TW', 'CHINESE_TRADITIONAL', 'ux-flag-zh-TW'],['hr', 'CROATIAN', 'ux-flag-hr'],['cs', 'CZECH', 'ux-flag-cs'],
                           ['da', 'DANISH', 'ux-flag-da'],['nl', 'DUTCH', 'ux-flag-nl'],['en', 'ENGLISH', 'ux-flag-en'],
                           ['et', 'ESTONIAN', 'ux-flag-et'],['tl', 'FILIPINO', 'ux-flag-tl'],['fi', 'FINNISH', 'ux-flag-fi'],
                           ['fr', 'FRENCH', 'ux-flag-fr'],['gl', 'GALACIAN', 'ux-flag-gl'],['de', 'GERMAN', 'ux-flag-de'],
                           ['el', 'GREEK', 'ux-flag-el'],['iw', 'HEBREW', 'ux-flag-iw'],['hi', 'HINDI', 'ux-flag-hi'],
                           ['hu', 'HUNGARIAN', 'ux-flag-hu'],['id', 'INDONESIAN', 'ux-flag-id'],['it', 'ITALIAN', 'ux-flag-it'],
                           ['ja', 'JAPANESE', 'ux-flag-ja'],['ko', 'KOREAN', 'ux-flag-ko'],['lv', 'LATVIAN', 'ux-flag-lv'],
                           ['lt', 'LITHUANIAN', 'ux-flag-lt'],['mt', 'MALTESE', 'ux-flag-mt'],['no', 'NORWEGIAN', 'ux-flag-no'],
                           ['pl', 'POLISH', 'ux-flag-pl'],['pt', 'PORTUGUESE', 'ux-flag-pt'],['ro', 'ROMANIAN', 'ux-flag-ro'],
                           ['ru', 'RUSSIAN', 'ux-flag-ru'],['sr', 'SERBIAN', 'ux-flag-sr'],['sk', 'SLOVAK', 'ux-flag-sk'],
                           ['sl', 'SLOVENIAN', 'ux-flag-sl'],['es', 'SPANISH', 'ux-flag-es'],['sv', 'SWEDISH', 'ux-flag-sv'],
                           ['th', 'THAI', 'ux-flag-th'],['tr', 'TURKISH', 'ux-flag-tr'],['uk', 'UKRANIAN', 'ux-flag-uk'],
                           ['vi', 'VIETNAMESE', 'ux-flag-vi']];


Ext.translate.URL='http://ajax.googleapis.com/ajax/services/language/translate';

/**
Ext.Ajax.request( {
	
	//url : 'http://ajax.googleapis.com/ajax/services/language/translate',
	url : 'http://www.google.com/uds/Gtranslate',
	async : false,
    isJSON    : true,

    proxied   : {
        debug        :false ,
        callbackParam: 'callback'
        },
	params : {             
			q : 'hello',
			v: '1.0',
			langpair : 'en|hr',
			key : 'notsupplied'
		},
	callback : function(options,success,response){

            alert(response.responseText);
        }
});
*/


/**
 * Create languagge pair for translation...
 * @param strings with language name ENGLISH,CROATIAN
 * @return String of language pairs...en|hr
 */
Ext.translate.Manager.getLanguagePair = function(fromLang, toLang){
	var fl, tl;
	
	for(var langs in Ext.translate.languages){
		if (Ext.translate.languages[langs][1]==fromLang){
			fl = Ext.translate.languages[langs][0];
		};
		
		if (Ext.translate.languages[langs][1]==toLang){
			tl = Ext.translate.languages[langs][0];
		};
	};
	
	return fl+'|'+tl;
	
};

/**
 * Returns Google Translation Service URL query
 * http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&langpair=en|hr&q=Today%20is%20a%20fine%20day
 * @param Strings of language pari returned from getLanguagePair and data to translate
 */
Ext.translate.Manager.getGTArequest = function(pair , text){
	var obj = {langpair: pair, q: text, v : '1.0', key :'notsupplied' , callbackFn : 'callback'};

	return obj;
};


